{extend name="public:base" /}
{block name="content"}
<link rel="stylesheet" href="__CSS__/addcomon.css">
<div class="row" style="padding:15px;">
    <div class="col-xs-12">
        <form id="form">
            <div class="box">
            <div class="box-header" data-original-title="" style="height: 40px;">
                <h2><i class="glyphicon glyphicon-plus"></i>添加菜单</h2>
            </div>
            <div class="add-box">
                <div class="box-left">
                    <div class="form-group">
                        <label>父级菜单:</label>
                        <select class="form-control" name="pid" required>
                            <option value="0">--默认顶级--</option>
                            {volist name="authrule" id="vo"}
                                <option value="{$vo.id}" {eq name="info.pid" value="$vo['id']"}selected{/eq}>{$vo.lefthtml}{$vo.title}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="form-group">
                        <label>菜单名称:</label>
                        <input type="text" name="title" required class="form-control" value="{$info.title}">
                    </div>
                    <div class="form-group">
                        <label>控制器/方法:</label>
                        <input type="text" name="name" required  class="form-control" value="{$info.name}">
                    </div>
                    <div class="form-group">
                        <label>排序:</label>
                        <input type="text" name="sort" class="form-control" value="{$info.sort}">
                    </div>

                </div>
                <div class="box-right">
                    <div class="form-group">
                        <label>样式名称：</label>
                        <input type="text" name="css" placeholder="只针对顶级栏目有效，例:fa-tachometer.." class="form-control" value="{$info.css}">
                    </div>
                    <div class="form-group">
                        <label for="">是否显示:</label>
                        <input name="status" value="1" type="checkbox" {eq name="info.status" value='1'}checked{/eq}/>
                    </div>
                    <div class="form-group">
                        <label>权限是否检测:</label>
                        <input name="notcheck" value="0" type="checkbox" {eq name="info.notcheck" value='0'}checked{/eq}/>
                    </div>
                </div>
                <div class="btn-box">

                    <button type="button" class="btn btn-color-o" id="submit">确定</button>
                    <button type="reset" class="btn btn-color-g">返回</button>
                </div>

            </div>
        </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script>
    $('#submit').click(function () {
        $.ajax({
            type: "POST",
            url:  "{:url('addrun')}",
            data: $('#form').serialize(),
            beforeSend:function(){
                $(this).attr("disabled","false"); //禁止点击
            },
            success: function(info){
                console.log(info);
                if(info.code==1){
                    layer.msg(info.msg, {icon: 1});
                    setTimeout(function(){
                        location.href=info.url;
                    },3000); //延迟演示
                }else{
                    layer.msg(info.msg, {icon: 5});
                    $('#submit').removeAttr("disabled"); //禁止点击
                }

            }
        });
        return false;
    });
    highlight_subnav("{:url('index')}");
</script>

{/block}